<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Connexion_model extends CI_Model
{
    
    public function __construct()
    {
        parent::__construct();
    }
    
    public function check($email, $password)
    {
        $result = $this->db->select('identifiant, motdepasse')
						   ->from('utilisateur')
                           ->where('courriel', $email)
                           ->limit(1)
                           ->get()
                           ->result();
        if(sizeof($result) == 1)
        {
            if($result[0]->motdepasse == $password)
            {
                return $result[0]->identifiant;
            }
            else
            {
                return -1;
            }
        }
        else
        {
            return 0;
        }
    }
    
    public function get_user_informations($identifiant)
    {
		$result = $this->db->select('nom, prenom, courriel')
                           ->from('utilisateur')
                           ->limit(1)
                           ->get()
                           ->result();
                           
		return $result[0];
    }
}
